
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BusinessObject;
using DataAccessLayer;

namespace BusinessLogic
{
    /// <summary>
    /// Define UserProfileUtil class. This class user for BussinessLayer.

    /// </summary>
    public class UserProfileUtil
    {
        /// <summary>
        /// Define function Insert for UserProfile Object.
        /// </summary>
        /// <param name="t">object data need Insert.</param>
        /// <returns>
        ///    True: if insert successfull.
        ///    False: if insert error.
        ///</returns>
        public static bool Insert(UserProfile t)
        {
            BizObject.PurgeCacheItems("UserProfile");

            return UserProfileDao.Insert(t);
        }
        /// <summary>
        /// Define function Update for UserProfile Object.
        /// </summary>
        /// <param name="t">project data need updated.</param>
        /// <returns>
        ///    True: if update successful.
        ///    False: if update Error.
        ///</returns>
        public static bool Update(UserProfile t)
        {
            BizObject.PurgeCacheItems("UserProfile");

            return UserProfileDao.Update(t);
        }
        /// <summary>
        /// Get All UserProfile object from table UserProfile.
        /// </summary>
        /// <returns>List UserProfile object.</returns>
        public static List<UserProfileResult> GetAll()
        {
            List<UserProfileResult> obj = null;
            string key = "UserProfile_GetAll";
            if (BizObject.Cache[key] != null)
            {
                obj = (List<UserProfileResult>)BizObject.Cache[key];
            }
            else
            {
                obj = UserProfileDao.GetAll();
                BizObject.CacheData(key, obj);
            }
            return obj;
        }
        /// <summary>
        /// Search UserProfile object in table UserProfile.
        /// </summary>
        /// <param name="t">Condition for Search.</param>

        /// <returns>List UserProfileResult objects.</returns>

        public static List<UserProfileResult> SearchUserProfileSomeCondition(UserProfile t)
        {
            return UserProfileDao.SearchUserProfileSomeCondition(t);
        }
        /// <summary>
        /// Get a UserProfile data object by primary key. 
        /// </summary>
        /// <param name="userId" >This is primary key.</param>
        /// <returns>A UserProfile object.</returns>

        public static UserProfile Get(Guid userId)
        {
            UserProfile obj = null;
            string key = "UserProfile_Get_" + string.Format("{0}", userId);
            if (BizObject.Cache[key] != null)
            {
                obj = (UserProfile)BizObject.Cache[key];
            }
            else
            {
                obj = UserProfileDao.Get(userId);
                BizObject.CacheData(key, obj);
            }
            return obj;
        }

        /// <summary>
        /// This function to Delete UserProfile object by primary key.
        /// </summary>
        /// <param name="userId" >This is primary key.</param>
        /// <returns>If succesful return True else  return False.</returns>

        public static bool Delete(Guid userId)
        {
            BizObject.PurgeCacheItems("UserProfile");

            return UserProfileDao.Delete(userId);
        }
        public static UserProfile Get(string application,Guid userId)
        {
            UserProfile obj = null;
            string key = "UserProfile_Get_" +  application + "_" + userId;
            if (BizObject.Cache[key] != null)
            {
                obj = (UserProfile)BizObject.Cache[key];
            }
            else
            {
                obj = UserProfileDao.Get(userId,application);
                BizObject.CacheData(key, obj);
            }
            return obj;
        }
        public static Vw_aspnet_RolesResult GetMaxRole(Guid userId,string application)
        {
            return UserProfileDao.GetMaxRole(userId,application);
        }
        public static Vw_aspnet_RolesResult GetRoleByName(string application, string roleName)
        {
            return UserProfileDao.GetRoleByName(application, roleName);
        }
    }
}